using Godot;

public class CampfireView : StoreView
{
    Slot[] blockslot = new Slot[5];
    TextureProgress progress;
    public override void _Ready()
    {
        base._Ready();
        ResetShiftClick();
        progress = GetNode<TextureProgress>("TextureProgress");
        for (int i = 0; i < 4; i++)
        {
            blockslot[i] = GetNode<Slot>($"{i}");
            blockslot[i].index = i;
            blockslot[i].OnClickEvent = ClickSlot;
            blockslot[i].OnShiftClickEvent = ShiftClickSlot;
            blockslot[i].HoldIn = BlockHoldIn;
            blockslot[i].HoldOver = HoldOver;
        }
    }
    public override void Updata(Player player)
    {
        base.Updata(player);
        if (block != null)
        {
            CampfireBlockEntity cbe = block.blockEntity as CampfireBlockEntity;
            Store stroe = block.blockEntity.GetStore();
            for (int x = 0; x < 4; x++)
            {
                blockslot[x].SetItemStack(stroe.GetItemStack(x));
            }
            progress.Value = ((float)cbe.Pace / (float)CampfireBlockEntity.MaxPace) * 100f;
            if (progress.Value <= 0f) progress.Visible = false;
            else progress.Visible = true;
        }
    }
}
